Repository navigation
guest: require digits on both sides of a syslog timestamp's point - #2214
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 26, 2026
Merged
Conversation
SyslogLine::parse, which the time ABI's boot check C4 and nvx-time-probe's syslog(2) fallback use to split a kernel log line, took a leading bracket whose seconds or fraction held no digit for a timestamp: `<6>[.] message` parsed as 0 s, `<6>[5.] message` as 5 s, and `<6>[ .5] message` as 0.5 s, each without the bracket in its message. Its rustdoc says that a timestamp is decimal seconds with a decimal fraction and that a line whose brackets hold anything else keeps them in its message, and the kernel writes its timestamps as `[%5lu.%06lu]`. C4, which exempts the time tools' own NVX-TIME- records by the start of the message, then also exempted a line such as `<6>[.] NVX-TIME-...`, and the probe printed such a message with a fabricated timestamp. Reported in #2211. `microseconds` checked only that the seconds and the fraction held nothing but digits, which empty text satisfies, and read empty seconds as 0: a leniency of the time ABI decoder's former `syslog_message`, which 2ac2ce1 kept when it merged that reader with the probe's into `SyslogLine`. It now reads the seconds with the shared `parse_decimal`, which refuses empty text, and requires one or more digits in the fraction. A fraction of another length than the kernel's six digits, such as that of `[12.5]`, still parses as before. The rustdoc of both functions says so. Evidence, on this Windows workstation's default WSL 2 distribution (Linux 6.18.58.1-microsoft-standard-WSL2) with Rust 1.97.1, since the guest module builds only on Linux, and the reachable configured Linux hosts, azure-intel-kvm-1 and azure-intel-mshv-1, are CI runners without a checkout or a Rust toolchain: at c074bf6, the new test fails, as `<6>[.] message` parses as (Some(0), "message"); with the change, `cargo test --locked --features guest --lib` passes, 1249 tests passed and 42 ignored, which need root, capabilities, or an environment of their own. Tests: the new kernel_text test syslog_brackets_without_seconds_or_fraction_digits_stay_in_the_message fails at c074bf6 and passes with the change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the kernel syslog parser change.
No open issues 🎉
What changed in this PR
Fixes #2211 by tightening the shared kernel syslog parser used by the guest time tools. Malformed timestamp brackets now remain part of the message rather than producing a fabricated timestamp.
Changes:
- Require at least one digit on each side of the timestamp’s decimal point.
- Add regression coverage for
[.],[5.], and[ .5]. - Clarify the parser documentation while preserving support for valid variable-length fractions.
| File | Description |
|---|---|
nvx/src/guest/kernel_text/tests.rs |
Tests that malformed timestamps retain their brackets and yield no timestamp. |
nvx/src/guest/kernel_text.rs |
Rejects empty seconds or fractions and documents the accepted format. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
deleted the
agents/issue-2211-syslog-timestamp-digits
branch
November 26, 2026 19:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2211
What does this pull request change?
SyslogLine::parseinnvx/src/guest/kernel_text.rs, the reader of kernellog lines as
syslog(2)returns them, which the time ABI's boot check C4 innvx-timeandnvx-time-probe's fallback share, now takes a leading bracketfor a timestamp only when its seconds and its fraction each hold one or more
digits.
<6>[.] message,<6>[5.] message, and<6>[ .5] messagenow keeptheir brackets in their messages and have no timestamp, as
<6>[abc] messagealready did; before, they parsed as 0 s, 5 s, and 0.5 s, without their
brackets. The kernel's own timestamps,
[%5lu.%06lu], and fractions of otherlengths, such as that of
[12.5], parse as before.Start at
microseconds, which now reads the seconds with the sharedguest::parse::parse_decimal, which refuses empty text, and requires anonempty fraction of digits. The rustdoc of it and of
SyslogLine::parsesaysso, and the new test
syslog_brackets_without_seconds_or_fraction_digits_stay_in_the_messagecovers the three forms.
It changes no consumer of the reader: C4's exemption of the time tools' own
NVX-TIME-records still tests the start of a line's message, which now keepsa malformed bracket.
Why is this change needed?
microsecondschecked only that the seconds and the fraction held nothing butdigits, which empty text satisfies, and read empty seconds as 0. That
leniency comes from the time ABI decoder's former
syslog_message, whichskipped zero or more digits on each side of the point;
2ac2ce1a20ckept itwhen it merged that reader with the probe's into
SyslogLine, although itdocumented the strict form, and its message says that the tools read the
kernel's text "only in the form in which they are written".
The impact is low, as #2211 describes: NVX's guest kernel stamps every line
(
CONFIG_PRINTK_TIME=y), so such a bracket comes first only when a commandline sets
printk.time=0and a message's own text starts with one. Then C4also exempted a line such as
<6>[.] NVX-TIME-...from its W+X, watch-rule,and forbidden-record checks, and the probe printed such a message with a
fabricated timestamp and without its bracket.
Rejected alternatives: requiring exactly the kernel's six fraction digits,
which the rustdoc and the existing test, with
[12.5], do not ask for and noreader needs; and documenting the empty parts as accepted, which would keep a
form that the kernel never writes and the misreading of messages that start
with one.
How was this change validated?
Checks and results:
Reproduced at the base,
c074bf631d2: the new test fails there, as<6>[.] messageparses as(Some(0), "message"), and passes with the fix.cargo test --locked --features guest --lib(fromnvx/) passes with thefix: 1249 passed, 0 failed, 42 ignored, which need root, capabilities, or an
environment of their own.
python scripts\local_gates.py --base origin/dev --runon Windows, with arelease
nvxbuilt so thatNVXnames it:test-changes(0 changes toexisting tests, 1 added),
markdown-links,test-layout,nvx-format,nvx-lint,nvx-test,nvx-doc,nvx-msrv, andnvx-cli(2326 tests OK,89 skipped;
test_adversarial.py84 OK, 11 skipped) passed. These Rust gatesdo not compile
nvx/src/gueston Windows, so the Linux run below is the onethat checks the change.
python3 scripts/local_gates.py --base origin/dev --runin WSL 2, in a cloneof
25317d20b70, whose tree the head,e0ca73a51be, keeps with a rewordedmessage, with a temporary
python→python3link onPATH:test-changes,markdown-links,test-layout,nvx-format,nvx-lint,nvx-test(1870 lib tests with all features passed, 59 ignored),nvx-doc,nvx-public-api,nvx-msrv,nvx-macos,nvx-guest-binaries-lint, andnvx-guest-binaries-buildpassed.nvx-clistopped at its first command,python3 -m pip install --requirement scripts/setup/azure/requirements.txt,which the distribution's Python refuses (
externally-managed-environment);its only requirement, PyYAML 6.0.3, is installed, and the gate's remaining
commands passed: 2326 tests OK (41 skipped),
test_adversarial.py84 OK, andthe
nvx.pyhelp checks.A code-review pass of the branch's diff found no issue.
Runtime check in WSL 2 with KVM: the
nvx-timeof releasev0.1.0-dev.0d2ea37c50be, whosenvx/,guest/, andkernel/equal thebase's, taken from its Alpine initramfs (sha256
a45929c7…), and the fixedone that this commit's guest-binary build produced (sha256
d6e1e5ed…), eachrunning C4's scan of a log,
nvx-time test syslog LOG, on real guest bootlogs read through
syslog(2)(dmesg -r -S) from guests booted with therelease's artifacts and
--cpu-profile host:nvx-timenvx-timeokokprintk.time=0, 173 unstamped linesokok<6>[.] NVX-TIME-x kvm-clock: Using msrsok: exempted as an own recordfail forbidden record: [.] NVX-TIME-x kvm-clock: Using msrs<4>[5.] NVX-TIME-x x86/mm: Found insecure W+X mapping at address 0xffffffffc0000000ok, no W+Xok, thenwx [5.] NVX-TIME-x x86/mm: Found insecure W+X mapping at address 0xffffffffc0000000The
printk.time=0log confirms the trigger: itssyslog(2)lines carry notimestamp, so a message's own leading bracket comes first.
Backend, host OS, host type, and guest: the unit tests and Linux gates ran in
this Windows 11 workstation's default WSL 2 distribution (Linux
6.18.58.1-microsoft-standard-WSL2, Rust 1.97.1), and the guests booted there
on KVM, an Alpine guest of release
v0.1.0-dev.0d2ea37c50bewith--cpu-profile host, a WSL fallback with no recorded host type; the Windowsgates ran natively on that workstation.
nvx_hosts.py selectreachedazure-intel-kvm-1,azure-intel-mshv-1, andazure-intel-whp-1(virtual-machine), but they are GitHub Actions runners with no configured
checkout, and
azure-intel-kvm-1has no Rust toolchain, so no check ran onthem;
azure-intel-kvm-2,azure-intel-kvm-5,azure-intel-mshv-3,azure-intel-mshv-5,azure-intel-whp-2,azure-intel-whp-3,azure-intel-whp-6,azure-intel-whp-7, andazure-intel-whp-12wereunreachable.
test-microvm --backend kvm --scenario time-abi-conformancecouldnot run in WSL: its guest boots with
--cpu-profile auto, and WSL's KVM refusesthe built-in
intel.alderlake.v1withE_PROFILE_UNSUPPORTED(MSR 0x10a bits8, 17). No initramfs with the fixed binaries was packed, as WSL lacks
cpio,so no guest booted with them.
CI: run 45820231220
of the head,
e0ca73a51be, passed, with the guest artifacts built from thischange: the microVM tests on KVM, MSHV, and WHP, both shards and the guests
and sandboxes of each, and MSHV's debug kernel; the platform jobs of the three
backends; the packages;
nvxonubuntu-latestandwindows-latest; the NVXCLI on Linux and Windows; the quality gates; and
Required status check.Checklist
python3 scripts/check_test_layout.pychecks.python3 scripts/check_test_changes.py --base origin/devlists no changeto an existing test, or a Changes to existing tests section below
explains each one.
.github/copilot-instructions.mdand the skills when a convention orworkflow changes.
nvxupdatesnvx/public-api/withpython3 scripts/public_api.py --update.description says how the change versions or migrates them.